Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memoize cloned element in tooltip #167

Merged
merged 5 commits into from
May 15, 2024
Merged

Conversation

florianduros
Copy link
Member

No description provided.

Copy link

cloudflare-workers-and-pages bot commented May 14, 2024

Deploying compound-web with  Cloudflare Pages  Cloudflare Pages

Latest commit: 05e7e3d
Status:⚡️  Build in progress...

View logs

@florianduros florianduros marked this pull request as ready for review May 14, 2024 16:13
@florianduros florianduros requested a review from a team as a code owner May 14, 2024 16:13
@florianduros florianduros requested review from dbkr and robintown and removed request for a team May 14, 2024 16:13
...children.props,
});
return cloneElement(children, props);
}, [ref, children, isValidElement(children) && children.props]);
Copy link
Member

@t3chguy t3chguy May 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

&& here is unexpected, it implies breaking rules-of-hooks, can it get a comment to explain it?

Copy link
Member Author

@florianduros florianduros May 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it breaking the rules of hooks? I can declare it before but it doesn't change anything to me

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see. I added a comment. It's needed to be able to infer the type of children to have access to the props field.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was more questioning why && instead of , - a comment or maybe breaking it out into a sanely named variable could go a long way to clarifying it

@florianduros florianduros requested a review from t3chguy May 15, 2024 07:47
@florianduros florianduros merged commit 197304c into main May 15, 2024
4 of 5 checks passed
@florianduros florianduros deleted the florianduros/memoize-tooltip branch May 15, 2024 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants